<table id="permits" class="easyui-datagrid"
	   data-options="
				url: '${app}/sysmgr/permit/list.do',
				queryParams: {moduleId: ${RequestParameters['moduleId']}},
				method: 'post',
				fitColumns: true,
				singleSelect: true,
				toolbar: '#permit',
				onLoadSuccess: onLoadSuccess
			" style="width:100%;height:100%;">
	<thead>
	<tr>
		<th data-options="field:'permit_name',width:50">资源名称</th>
		<th data-options="field:'permit_url',width:120">资源地址</th>
		<th data-options="field:'operating',width:60,formatter:getPermitBtn">操作</th>
	</tr>
	</thead>
</table>
<div id="permit" style="height:auto">
	<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="parent.easyui.createWindow('资源新增', '${app}/sysmgr/permit/edit.do?moduleId=${moduleId}', '650px', '300px', window.name);">新增</a>
</div>
<script type="text/javascript">
	function getPermitBtn(value, row, index) {
		return '<a href="javascript:;" class="easyui-linkbutton" onclick="deletePermit('+row.permit_id+')">删除</a>&nbsp;'+
				'<a href="javascript:;" class="easyui-linkbutton" onclick="parent.easyui.createWindow(\'资源修改\', \'${app}/sysmgr/permit/edit.do?method=edit&moduleId=${moduleId}&permitId='+row.permit_id+'\', \'650px\', \'300px\', window.name);">编辑</a>&nbsp;'+
				'<a href="javascript:;" class="easyui-linkbutton" onclick="permitRole('+row.permit_id+')">权限</a>&nbsp;';
	}
	function reloadPermit(){
		$('#permits').datagrid('reload');
	}
	function deletePermit(permitId){
		parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
			if (r){
				parent.layer.load(2);
				common.ajax('${app}/sysmgr/permit/delete.do', 'permitId='+permitId,
					'POST', 'json', false,
					function(result){
						parent.layer.closeAll('loading');
						parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
						if (result.result == 1) {
							reloadPermit();
						}
					}
				);
			}
		});
	}
	function permitRole(permitId){
		parent.easyui.createWindow('资源角色', '${app}/sysmgr/permit/role.do?permitId='+permitId, '650px', '300px', window.name);
	}
</script>